package 设计模式.d_原型模式;

import java.io.*;

/**
 * 原型模式，允许通过现有对象创建其副本，无需经历从头开始创建对象并设值的过程
 * 优点：性能优秀
 * 缺点：深克隆麻烦，坑多
 * @author caihe
 * @date 2023/3/9 15:05
 */
public class Test {

    public static void main(String[] args) {

        FactoryImpl goldFactory = new FactoryImpl(new GoldCoin(), new GoldStar());
        Coin coin = goldFactory.copyCoin();
        Star star = goldFactory.copyStar();
        System.out.println(coin.getDesc());
        System.out.println(star.getDesc());
        

        goldFactory = new FactoryImpl(new CopperCoin(), new CopperStar());
        coin = goldFactory.copyCoin();
        star = goldFactory.copyStar();
        System.out.println(coin.getDesc());
        System.out.println(star.getDesc());

    }
    
}